package com.apes.hr.base.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：岗位分组
 * @author HuJianlin
 * @create 2018-08-25 15:11
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = WorkPostGroup.CONST_TABLE_NAME)
public class WorkPostGroup extends Model {
    public static final String CONST_TABLE_NAME = "hr_work_post_group";

    @Id
    @Column(name = "id", nullable = false, length = 120)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "岗位分组编码", padding = 7)
    private String id; //岗位分组编码

    @Name
    @Column(name = "name", nullable = false, length = 200)
    @Comment("岗位分组名称")
    private String name; //岗位分组名称

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "job_function", referencedColumnName = "id")
    @Comment("岗位职能")
    private Enumeration jobFunction;

    @Column(name = "valid", nullable = false,  columnDefinition = "number(1,0) default 1")
    private boolean valid = true; //有效

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "job_type", referencedColumnName = "id")
    @Comment("岗位类型")
    private Enumeration jobType;

}
